package com.netted.operationassistant.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.jude.rollviewpager.adapter.StaticPagerAdapter;
import com.netted.operationassistant.R;
import com.netted.operationassistant.activity.MenuActivity;

/**
 * Created by lu on 2018/6/28.
 */

public class ImageAdapter extends StaticPagerAdapter{
    private Context context;
    public ImageAdapter(Context context){
        this.context = context;
    }

    private int[] imgs = {
        R.drawable.bg
    };
    @Override
    public View getView(ViewGroup container, int position) {
    ImageView view = new ImageView(container.getContext());
    view.setImageResource(imgs[position]);
    view.setScaleType(ImageView.ScaleType.CENTER_CROP);
    view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    view.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = new Intent(context, MenuActivity.class);
            context.startActivity(intent);
        }
    });
    return view;
}

    @Override
    public int getCount() {
        return imgs.length;
    }
}
